/*
 * CajaHelper.java
 *
 * Created on 13 de septiembre de 2007, 11:11 AM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package com.src.computec.radar.despachos.caja.helper;

import com.src.computec.radar.base.dao.exception.DAOException;
import com.src.computec.radar.despachos.base.helper.BaseHelper;
import com.src.computec.radar.despachos.caja.dao.BaseCajaDAO;
import com.src.computec.radar.despachos.caja.dto.CajaDto;
import com.src.computec.radar.despachos.caja.exception.CajaException;
import com.src.computec.radar.despachos.despacho.dto.DespachoDto;
import java.util.Hashtable;
import java.util.List;

/**
 *
 * @ahor aocampo
 */
public class CajaHelper extends BaseHelper {
    
    /** Creates a new instance of CajaHelper */
    public CajaHelper() {
    }
    
    public CajaDto getCajaByPrimaryKey(CajaDto dto) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            return dao.getCajaByPrimaryKey(dto);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:getCajaByPrimaryKey:" + e.toString());
        }
    }
    
    public String insertCaja(CajaDto dto, String ldapUser) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            return dao.insertCaja(dto, ldapUser);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:insertCaja:" + e.toString());
        }
    }
    
    public int llenarCaja(CajaDto dto, String codigoBarrasInicial, String codigoBarrasFinal, boolean recuperacion, String ldapUser, Hashtable inconsistenciasHashTable) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            return dao.llenarCaja(dto, codigoBarrasInicial, codigoBarrasFinal, recuperacion, ldapUser, inconsistenciasHashTable);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:llenarCaja:" + e.toString());
        }
    }
    
    public int llenarCaja(CajaDto dto, List listListado, boolean recuperacion, String ldapUser, Hashtable inconsistenciasHashTable) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            return dao.llenarCaja(dto, listListado, recuperacion, ldapUser, inconsistenciasHashTable);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:llenarCaja:" + e.toString());
        }
    }
    
    public void vaciarCaja(List listDetallesLabel, CajaDto dto) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            dao.vaciarCaja(listDetallesLabel, dto);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:vaciarCaja:" + e.toString());
        }
    }
    
    public List getNodosByCaja(CajaDto dto) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            return dao.getNodosByCaja(dto);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:getNodosByCaja:" + e.toString());
        }
    }
    
    public List getDetallesLabel(CajaDto dto) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            return dao.getDetallesLabel(dto);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:getDetallesLabel:" + e.toString());
        }
    }
    
    public List getCajasByDespacho(DespachoDto dto) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            return dao.getCajasByDespacho(dto);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:getCajasByDespacho:" + e.toString());
        }
    }
    
    public boolean hasCloseCaja(CajaDto dto) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            return dao.hasCloseCaja(dto);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:hasCloseCaja:" + e.toString());
        }
    }
    
    public void cambiarEstadoCaja(CajaDto dto, String ldapUser) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            dao.cambiarEstadoCaja(dto, ldapUser);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:cambiarEstadoCaja:" + e.toString());
        }
    }
    
    public int validarCaja(CajaDto dto, List listListado, Hashtable validacionesHashTable) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            return dao.validarCaja(dto, listListado, validacionesHashTable);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:validarCaja:" + e.toString());
        }
    }
    
    // <editor-fold defaultstate="collapsed" desc="method disabled: transferCajas()">
    /*public void transferCajas(String codigoDespacho, List listCajasSeleccion) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            dao.transferCajas(codigoDespacho, listCajasSeleccion);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:transferCajas:" + e.toString());
        }
    }*/
    // </editor-fold>
    
    public void deleteCaja(CajaDto dto) throws CajaException {
        BaseCajaDAO dao = (BaseCajaDAO) this.getFactoryDAO().getCajaDAO();
        try {
            dao.deleteCaja(dto);
        }
        catch (DAOException e) {
            throw new CajaException("CajaHelper:deleteCaja:" + e.toString());
        }
    }
}